package com.wf.love.service;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wf.common.util.DateUtil;
import com.wf.love.bean.SimpleLoveShow;
import com.wf.love.dao.LoveShowDao;
import com.wf.love.entity.LoveShow;

@Service
public class LoveShowServiceImpl implements LoveShowService{

	@Autowired
	private LoveShowDao loveShowDao;
	
	public boolean addLoveShow(LoveShow loveShow) {

		return loveShowDao.addLoveShow(loveShow);
	}

	public List<SimpleLoveShow> getLoveShows(int page,int pageSize) {
		List<SimpleLoveShow> loves=new ArrayList<SimpleLoveShow>();
		List<LoveShow> loveShows=loveShowDao.getLoveShows(page,pageSize);
		SimpleLoveShow info=null;
		for (LoveShow loveShow : loveShows) {
			info=new SimpleLoveShow();
			info.setAddTime(DateUtil.dataFormat(loveShow.getAddTime(),"yyyy-MM-dd HH:mm:ss"));
			info.setContent(loveShow.getContent());
			info.setIpregion(loveShow.getIp());
			info.setNickname(loveShow.getNickname());
			info.setTitle(loveShow.getTitle());
			info.setIpregion(loveShow.getIpregion());
			loves.add(info);
		}
		return loves;
	}

}
